import * as Cesium from 'cesium'
// Cesium.Material.DiffusionEllipse = 'DiffusionEllipse'
export const DiffusionEllipse = 'DiffusionEllipse'


Cesium.Material._materialCache.addMaterial(DiffusionEllipse, {
    fabric: {
        type: DiffusionEllipse,
        uniforms: {
            // 这里必须有默认值吗?
            color: new Cesium.Color(),
            speed: 1,
            // frameNumber: 1,
        },
        source:
            'czm_material czm_getMaterial(czm_materialInput materialInput)\n' +
            '{\n' +
            '  czm_material material = czm_getDefaultMaterial(materialInput);\n' +
            '  material.diffuse = 1.5 * color.rgb;\n' +
            '  vec2 st = materialInput.st;\n' +
            '  float dis = distance(st, vec2(0.5, 0.5));\n' +
            '  float per = fract(czm_frameNumber * speed / 100.0);\n' +
            '  if(dis > per * 0.5) {\n' +
            '    material.alpha = 0.0;\n' +
            '    discard;\n' +
            '  }else{\n' +
            '    material.alpha = color.a * dis / per / 1.0;\n' +
            '  }\n' +
            '  return material;\n' +
            '}',
    },
    translucent: function (material) {
        return true
    },
})
